<?php namespace Common\Model;
use Hdphp\Model\Model;

class Register extends Model{
	protected $table = "360mall_user";
	protected $validate = array(
	  array("u_account","required","请输入手机号",3,3),
	  array("u_account","phone","请输入正确的手机号",3,3),
	  array("u_username","required","请输入用户名",3,3),
	  array("u_username","unique","用户名重复",3,3),
	  array("u_password","required","请输入密码",3,3),
	);
	public function store(){
		if(!$this->create()) return false;
		//判断验证码
        $code = strtolower($_POST['code']);
		$codes = strtolower(Code::get()) ;
		if($code!=$codes){
			$this->error= "验证码不正确";
			return false;
		}
		//判断两次密码是否一致
		$password =md5($_POST['u_password']);
		$repassword = md5($_POST['re_passeord']);
		if($password!=$repassword){
			$this->error= "两次密码不正确";
			return false;
		}
          //执行添加
		return $this->add();

	}
}